<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">信息管理</a>
        <a href="#">消息分类</a>
        <a href="#">添加子类</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:window.location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="height: 50px"></div>
    <div style="width: 300px">
        <form class="layui-form" action="" name="addType" onclick="return false" id="type">
            <input type="hidden" value="{$params.path}" name="path">
            <input type="hidden" value="{$params.pid}" name="parent_id">
            <div class="layui-form-item">
                <label class="layui-form-label">父类名称</label>
                <div class="layui-input-block">
                    <input type="text" value="{$params.title}" readonly placeholder="类别名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">子类名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" placeholder="类别名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" id="insert">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>
<script>
    $("#insert").click(function(){
        if(!$("input[name=title]").val()){
            layer.msg('类别名称不能为空',{icon:1,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/suggestion_type/typeInsert')}",
            data:$("#type").serialize(),
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.addType.reset();
                    });
                }else{
                    layer.msg(res.msg,{icon:5,time:2000})
                }
            }
        });
    })
</script>
</html>